#!/bin/bash
set -e
set -x
MYDIR="${0%/*}"
cd "$MYDIR/.."
source "recipes/common.sh"


# RECIPE START groff
# depends: cross-pkg-config

save_CFLAGS="$CFLAGS"
save_CPPFLAGS="$CPPFLAGS"
save_LDFLAGS="$LDFLAGS"
export CFLAGS='-O2 -g'
unset CPPFLAGS
unset LDFLAGS

reset_mtime groff groff/configure.ac
rm -rf build/groff-native
mkdir -p build/groff-native
cd build/groff-native

env \
	PAPER=A4 \
../../groff/configure \
	--host="$BUILD" \
	--build="$BUILD" \
	--disable-shared \
	--disable-silent-rules \
	--prefix="${build_prefix}" \
	${AUTOCRAP_KLUDGE}

cd ../..
make_native_build build/groff-native

export CFLAGS="$save_CFLAGS"
export CPPFLAGS="$save_CPPFLAGS"
export LDFLAGS="$save_LDFLAGS"

rm -rf build/groff
mkdir -p build/groff
cd build/groff
env PAPER=A4 \
../../groff/configure \
	${CONFIGURE_ARGS} \
	--disable-silent-rules \
	${AUTOCRAP_KLUDGE}

make -j${JOBS} TROFFBIN=troff GROFFBIN=groff GROFF_BIN_PATH=
make -j${JOBS} install DESTDIR="$stage" TROFFBIN=troff GROFFBIN=groff GROFF_BIN_PATH= 
cd ../..
rm -rf build/groff

# RECIPE END groff
